import pydantic
from pydantic import BaseModel, constr, UUID4, Field
from pydantic import ValidationError, validator
from typing import Optional, Union
from enum import Enum

class CurrEnum(str, Enum):
    RUR = "RUR"
    EUR = "EUR"
    CNY = "CNY"
    USD = "USD"

class sAccountCreate(BaseModel):
    cust_id: UUID4
    currency: CurrEnum
    amount: float = Field(ge=1000, le=10000000)
    interest_rate: float = Field(ge=0.1, le=20)
    duration_months: int = Field(ge=1, le=60)
    description: Optional[constr(max_length=150)]

class sAccountCheck(BaseModel):
    id: UUID4
    cust_id: UUID4

class sAccountsGet(BaseModel):
    cust_id: UUID4

class sAccountsDelete(BaseModel):
    id: UUID4
    cust_id: UUID4

class sAccountModify(BaseModel):
    id: UUID4
    cust_id: UUID4
    currency: CurrEnum
    top_up_amnt: Optional[float]
    withdraw_amnt: Optional[float]

    '''@pydantic.model_validator('before')
    def validate_exclusive_fields(cls, values):
        field1, field2 = values.get('top_up_amnt'), values.get('withdraw_amnt')
        if field1 is not None and field2 is not None:
            raise ValueError("Only one of top_up_amnt or withdraw_amnt can be specified")
        if field1 is None and field2 is None:
            raise ValueError("One of top_up_amnt or withdraw_amnt must be specified")
        if field1 is not None and field1 <= 0:
            raise ValueError("Top_up_amnt must be positive")
        if field2 is not None and field2 <= 0:
            raise ValueError("Withdraw_amnt must be positive")
        return values'''
